/**
 * @fileOverview hover node add outter
 * @author huangtonger@aliyun.com
 */
const Page = require('../../base/');

Page.registerBehaviour('hoverNodeAddOutter', diagram => {
  const graph = diagram.getGraph();
  let hoverNode;

  graph.behaviourOn('node:mouseenter', ({ item }) => {
    if (!diagram.getSignal('dragEdge')) {
      return;
    }
    hoverNode = item;
    diagram.addOutterShape(item, {
      stroke: '#52C41A',
      strokeOpacity: 0.45,
      lineWidth: 4
    });
  });
  graph.behaviourOn('node:mouseleave', () => {
    if (!hoverNode) {
      return;
    }
    diagram.clearOutterShape(hoverNode);
  });
  graph.behaviourOn('beforedropedge', () => {
    if (!hoverNode) {
      return;
    }
    diagram.clearOutterShape(hoverNode);
  });
});
